package br.com.engine.controle;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import br.com.engine.resources.PropertiesManager;


public class Tela extends JFrame 
{
	private static final long serialVersionUID = 1L;

	private static Tela tela;
	
	private Tela( )
	{
		super( "Meu primeiro jogo" );

		Integer width  = PropertiesManager.getInstance( ).getWidth( );
		Integer height = PropertiesManager.getInstance( ).getHeight( );
		
		setDefaultCloseOperation( EXIT_ON_CLOSE   );
		setIgnoreRepaint        ( true            );
		setSize                 ( width  != null ? width  : 400, 
				                  height != null ? height : 400 );
		
		addWindowListener( new WindowAdapter( )
		{
			public void windowClosing( WindowEvent e )
			{
				ControleBase.getInstance( ).stop( );
			}
		} );
		
		Tela.tela = this;
	}
	
	public static Tela getTela() {
		if( tela == null)
			tela = new Tela( );
		
		return tela;
	}
}